package com.igoal.entity;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class UserRolePk implements Serializable{
	private static final long serialVersionUID = -3004577567285362141L;
	
	private User user;
	private Role role;
	
	@ManyToOne
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@ManyToOne
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	
	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        UserRolePk that = (UserRolePk) o;
 
        if (user != null ? !user.equals(that.user) : that.user != null) return false;
        if (role != null ? !role.equals(that.role) : that.role != null) return false;
 
        return true;
	}
	
	@Override
	public int hashCode() {
		return this.user.hashCode()+this.role.hashCode();
	}
}
